Skip to content

fix(plugin-audit): an activity summary names a referenced record by a title the writer may read, else by its id - #34493

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/activity-summary-titles-in-writer-scope
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/activity-summary-titles-in-writer-scope

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:活动动态摘要里提到被引用的记录时(跟踪的查找字段变更、里程碑句子里的 {token}),记录名称按写入者自己的读取范围取得;写入者读不到该记录或其名称字段时,摘要写记录 id。
  • 为什么改:加固规则——活动摘要只用写入者本人可读的名称来指称被引用记录,否则用 id;与同一活动行的记录标签用同一读取范围。
  • 风险与回滚:只影响此后写入的活动行,已写入的行不变;有权读取的写入者和系统写入的摘要与之前相同;读取次数不变。回滚即 revert 本 PR,无数据迁移。
  • 先看:packages/plugins/plugin-audit/src/audit-writers.ts(两个摘要分支调用 resolveLookupTitles 的两处,以及该函数 "Whose read it is" 一节);packages/plugins/plugin-audit/src/activity-summary-title-writer-scope.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/activity-summary-title-writer-scope.test.ts,预期 1 个文件、11 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

Hardening rule: an activity summary names a referenced record by a title the writer may read, else by its id.

sys_activity.summary names a referenced record in two branches: the tracked-change diff (Vault: A → B) and a fired milestone's {token} (Escalated to {vault}). Both take the title from resolveLookupTitles in audit-writers.ts. Both now hand it the hook's own api, the writer's scope. The row's record label already reads there, so every title an activity row writes follows one rule.

  • A record the writer may not read keeps its stored id: the object refuses the writer, or the writer's row scope leaves the record out.
  • A record the writer may read without its title column keeps its stored id.
  • The rule holds per id. One change can title the side the writer may read and keep the id of the side it may not.
  • A writer who may read the target, and every system write, gets the same summary as before.
  • No read is added. It is still one id: { $in } read per distinct target object, and only when a tracked reference moved or a fired milestone names one.

The resolver's docblock now states the rule for every caller. Rows already written keep the summary they were written with.

Tests

New file src/activity-summary-title-writer-scope.test.ts (11 cases) runs a bare engine with the real installAuditWriters. The restrictions are engine middleware on the target object: a refused read, a row left out by row scope, and a row served without its title column. For each branch it pins the three restricted writers, a writer who may read and a system write. The tracked branch also pins the per-id case. The cases assert the stored sentence and the stored summary code that the read side composes from.

Red first: the new file against the base source

At origin/main bf76922925, before the fix:

 Test Files  1 failed (1)
      Tests  7 failed | 4 passed (11)

The 4 that pass are the controls (a writer who may read, and a system write, in each branch).

Ablations via scripts/ablation-replace.mjs, each restored to the HEAD blob with an empty git diff HEAD
Mutation Red
M1: the tracked-change branch's call takes its base-source argument again 4 (the three restricted writers and the per-id case)
M2: the milestone branch's call takes its base-source argument again 3 (the three restricted writers)

Each logged ok mutation landed: anchor 1 -> 0 and ok restored: blob == HEAD (b8e96db505a1) and git diff HEAD is empty.

Package suite and typecheck at 7c093c0 (after merging origin/main)

Closure rebuilt after the merge (turbo run build --filter=@objectstack/plugin-audit..., 16/16 tasks), @objectstack/spec check:generated reports all 14 generated artifacts up to date. Under scripts/pm/os-verify-lock.sh:

pnpm --filter @objectstack/plugin-audit test && pnpm --filter @objectstack/plugin-audit typecheck
 Test Files  100 passed (100)
      Tests  1665 passed (1665)
check:test-typecheck: OK — @objectstack/plugin-audit's test layer compiles
os-verify-lock: VERDICT command-exit 0

Acceptance notes

  • Scope. Only the two summary branches change. The record label already read its title in the writer's scope.
  • referenceNameVisible. A lookup that declares it follows the same rule in the summary as in the record label. Whether that key should widen what activity rows name is a question raised with the owning seat. This PR does not decide it.
  • Already-written rows keep the summary they were written with. Snapshots are not rewritten.
  • Test placement. The summary branches have no shared harness file (each audit suite carries its own), so the pins are a new file named for the rule.

Verification

Local gate subset: the scripts/pm/dispatch-gates.mjs --commands list derived at 7c093c01 (72 commands). 70 answered exit 0, one of them after its pinned fixture commit was fetched into this shallow clone. check:dual-build-cjs-loads refused locally (PREREQUISITE NOT MET: it reads every package's build output), and so did check:i18n (it needs the CLI build closure). Both are NOT MEASURED here. CI runs both in Lint & Repo Gates, and CI runs the full farm.


Generated by Claude Code

… title the writer may read, else by its id

Both summary branches that name a referenced record (the tracked-change
diff and a fired milestone's tokens) read the title in the writer's
scope, the scope the record label already reads in. An id whose record
or title column the writer may not read keeps its stored id.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRiaNzHVY81pCjZrpv
…title the writer may read

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRiaNzHVY81pCjZrpv
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 495a79c7b38c82b4ca4c840b387626b6a1a4b16e → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 748820e4452a6676a4cbfb1f48a463b4a8c41265 — the merge of head 7c093c01a1de80c60494979c5ade5751fd3a94d6 into base 495a79c7b38c82b4ca4c840b387626b6a1a4b16e, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 748820e4452a6676a4cbfb1f48a463b4a8c41265 && git checkout 748820e4452a6676a4cbfb1f48a463b4a8c41265
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 495a79c7b38c82b4ca4c840b387626b6a1a4b16e 7c093c01a1de80c60494979c5ade5751fd3a94d6 && git checkout -B drift-repro 495a79c7b38c82b4ca4c840b387626b6a1a4b16e && git merge --no-ff 7c093c01a1de80c60494979c5ade5751fd3a94d6

node scripts/docs-audit/affected-docs.mjs --json 495a79c7b38c82b4ca4c840b387626b6a1a4b16e

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-steve · session_01ADHkmRiaNzHVY81pCjZrpv
os-dev-report

{
  "issue": null,
  "status": "needs_decision",
  "branch": "claude/activity-summary-titles-in-writer-scope",
  "pr": "https://github.com/objectstack-ai/objectstack/pull/34493",
  "session": "session_01ADHkmRiaNzHVY81pCjZrpv",
  "premise_still_valid": true,
  "summary": "Both activity-summary branches that name a referenced record (tracked-change diff, fired-milestone token) now read the title in the writer's scope, the scope the record label already reads in (#34172); an id whose record or title column the writer may not read keeps its stored id, per id, with no read added. Draft PR #34493 (head 7c093c01, origin/main merged once) carries the fix, 11 rule-named pins in a new file, and a patch changeset stating the rule only. Status is needs_decision for ONE sub-case only: honouring a lookup's referenceNameVisible in activity rows the way $expand does needs a choice (see open_questions); the PR as written is option A, which names a declaring field's target by its id when the writer is refused it, the same as the record label already does. Landing the PR as is = choosing A.",
  "ruling_6574398310": {
    "url": "https://github.com/objectstack-ai/objectstack/issues/29171#issuecomment-6574398310",
    "author": "zhuangjianguo (director#1), 2026-11-02T10:05:41Z, maintainer approval quoted in the ruling",
    "verbatim_binding_section": "**What the ruling binds**\n\n- A new optional key on the referencing `lookup` field (name chosen by the `domain:spec` seat; meaning: \"a principal who can read this record may see the target record's display name\"). Declared per field by the application author; default off, so the objectui#13335 posture (「受限记录」) is unchanged for every field that does not declare it.\n- Placement is the referencing field, not the target object: the application decides whose name its own portal pages reveal. A target-object-level \"my name is public to every referrer\" switch is refused.\n- What the engine returns for such a field when the caller cannot read the target: the target's `nameField` value and the id, nothing else. `expand` on that field returns the same (name + id), never other fields. The same key covers `sys_user` names; no separate carve-out.\n- The console renders the name as text with no link to the target record.\n- Option A (every portal app keeps its own snapshot field + sync flow) and option C (every lookup returns the target name regardless of read access) are refused.",
    "how_it_bears": "The ruling governs what the engine and $expand return for a declaring field when the caller cannot read the target; it says nothing about activity rows. The engine serves it from serveReferenceNames (objectql, private method) after the caller's own expansion, gated by the caller's field-level answer on the name field (servableNameField). Neither is reachable from plugin-audit without exporting it from objectql (outside the file surface) or copying it."
  },
  "surface_grep_before_edit": "audit-writers.ts hits for ruling / maintainer / ⛔ were read; the binding one for this change is maintainer ruling Option A+ (#6656 / PR #6977: zero reads by default, one read per distinct target object on the write hot path). Honoured: the fix swaps the reader of the existing read and adds no read. No Ruling-ref hits.",
  "files_changed": [
    "packages/plugins/plugin-audit/src/audit-writers.ts (+26/-17: both summary call sites pass the hook api; resolveLookupTitles param renamed writerApi and its 'Whose read it is' docblock states the rule for every caller; two docblock lines aligned)",
    "packages/plugins/plugin-audit/src/activity-summary-title-writer-scope.test.ts (new, 11 cases)",
    ".changeset/activity-summary-titles-writer-scope.md (new, @objectstack/plugin-audit patch, Clause-②: no, Metadata-protocol: none)"
  ],
  "tests": "PREMISE on fresh origin/main bf76922925 (before any edit, new pin file only): `pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 src/activity-summary-title-writer-scope.test.ts` -> Test Files 1 failed (1) · Tests 7 failed | 4 passed (11); the 4 passing are the controls (allowed writer, system write, per branch). After the fix (526a97c7): that file + activity-lookup-name-field-label-34055 + audit-lookup-summary + audit-milestone-summary -> Test Files 4 passed (4) · Tests 70 passed (70). ABLATION (scripts/ablation-replace.mjs, src import so no dist leg; trap restore with absolute path): M1 tracked branch call reverted to its base-source argument -> 4 failed | 7 passed (11), 'ok mutation landed: anchor 1 -> 0', restored 'blob == HEAD (b8e96db505a1) and git diff HEAD is empty'; M2 milestone branch call reverted -> 3 failed | 8 passed (11), same landed/restored lines. FULL PACKAGE at merged head 7c093c01 under os-verify-lock: `pnpm --filter @objectstack/plugin-audit test && pnpm --filter @objectstack/plugin-audit typecheck` -> Test Files 100 passed (100) · Tests 1665 passed (1665) · check:test-typecheck OK (0 debt) · VERDICT command-exit 0. Closure rebuilt after the merge (turbo build --filter=@objectstack/plugin-audit..., 16/16) and `@objectstack/spec check:generated` -> all 14 generated artifacts up to date. test:repo not run locally (diff touches no repo-project test; CI Test Core).",
  "ablation": {
    "M1_tracked_change_branch": {
      "red": 4,
      "of": 11,
      "restored": "blob == HEAD b8e96db505a1, git diff HEAD empty"
    },
    "M2_milestone_branch": {
      "red": 3,
      "of": 11,
      "restored": "blob == HEAD b8e96db505a1, git diff HEAD empty"
    }
  },
  "gates": "Derived `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at 7c093c01 (stderr: tree objectstack-ai/objectstack @ 7c093c01, 3 paths vs merge base 3bf9c5c41) = 72 commands, each run with exit captured before any pipe. 69 exit 0 on the first pass; `node scripts/check-plugin-teardown-shape.mjs --self-test` exit 3 (pinned fixture commit 621a4876 not in the shallow clone) -> fetched that commit at depth 1 -> rerun exit 0 (48 cases). `pnpm check:dual-build-cjs-loads` exit 3 PREREQUISITE NOT MET (reads every package's dist) and `pnpm check:i18n` exit 3 PREREQUISITE NOT MET (needs the CLI build closure; two lock attempts timed out at 9 min each behind a sibling's runtime suite) -> both NOT MEASURED locally, declared narrowing. `dispatch-gates --ran` -> '72 derived, 70 run, 2 NOT-MEASURED, 0 UNRUN', exit 0. CI check-runs on 7c093c01 at report time (not waited on): success = Check Changeset, Check PR Size, PR-body guards, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Governed Surface Queue Guard, Flag docs affected by code changes, Dogfood Regression Gate, Test UI, Auto Label, filter; in_progress = Build Core, Plan Test Core shards (Test Core not yet listed), Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · docs & code guards, Lint · ESLint, Lint · scoped · query-options erasure, Lint · scoped · slot lookup & corpus, Type Check · workspace / source gates / consumer gates / debt ledger, Live E2E UI; the rest skipped by path. The two locally NOT MEASURED families ride the in_progress Lint jobs. check-platform-checklist not owed (no export renamed or removed).",
  "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
  "mcp_calls": "0",
  "api_writes": "2 — (1) relay pr_create: POST /repos/objectstack-ai/objectstack/dispatches (HTTP 204) -> fleet-write run 43974448338 success -> PR #34493 created draft, read-back 5927 bytes sent = stored, assignees none, labels none; (2) this report comment via scripts/pm/post-stamped.mjs on PR #34493 (POST /repos/objectstack-ai/objectstack/issues/34493/comments). Not REST: git push of the branch (4 pushes). Reads only otherwise (gh api GET of the ruling comment, PR #34172, recent PR bodies, check-runs).",
  "deviations": [
    "PR body carries two HTML comments (attribution first line, signed trailer last line) although os-dev bans HTML comments in GitHub text: the dispatch prescribed both, the relay header names the signed trailer as the PR-body signature form, and the stored body read back byte-identical. Named here, not chosen silently.",
    "Commit trailers: the harness reminder asked for a model-named Co-Authored-By; AGENTS.md's model-free pair (Co-authored-by: Claude, Claude-Session) was used, as AGENTS.md outranks the reminder.",
    "PR footer: AGENTS.md session-URL footer block used, not the harness's 'Generated with' form.",
    "No assignee on the PR: the dispatch forbade assignees (os-dev rule 2 would carry a claim Account, and a no-card order has no claim).",
    "Local narrowing: check:dual-build-cjs-loads and check:i18n NOT MEASURED (prerequisite refusals); CI's Lint & Repo Gates runs both.",
    "Shared .git touched additively: commit 621a4876 fetched at depth 1 into the common object store for a gate self-test fixture.",
    "New test file instead of a top-level describe in an existing one (ruling record 6583487846): the summary writer has no shared harness file; each audit suite carries its own, as #34172 also recorded."
  ],
  "governing_text": "ruling 6574398310 letter B (verbatim above); FieldSchema.referenceNameVisible description in packages/spec; ADR-0104 D1 (an unexpanded read answers the bare id for every caller); maintainer ruling Option A+ on the audit write hot path (#6656, cited in audit-writers.ts).",
  "open_questions": [
    {
      "question": "Should activity rows (the record label and both summary branches alike) honour a lookup's referenceNameVisible, naming a target the writer may not read by its display name the way $expand serves it?",
      "options": [
        "A — No, as this PR is written and as the record label already behaves since #34172: an activity row names a referenced record only by a title the writer may read in its own scope, else by its id; a declaring field whose target the writer is refused is named by its id. Business need (measured in this repo at 7c093c01, git grep): 0 fields declare the key in any metadata outside test fixtures (examples/ included), so 0 declaring fields are tracked or named in a milestone token; the ruling's named consumer (hotsrm portal pages) is outside this repo and unmeasured. Long-term: one read rule for every title an activity row writes, and no second copy of the engine's name rule. AI-error: fail-closed, no new key semantics for an author to misread. Startup focus: no new surface. Cost: an app that declares the key on a tracked lookup shows an id in the timeline where the record page shows the name. Effort: 0 (landed by this PR).",
        "B — Yes, identically to $expand, for the label and both summary branches: for a declaring field, an id the writer is refused (object gate or row scope) is named by the target's display name when the writer's field-level answer serves the name field and that field is title-eligible, unmasked and not a formula through a reference; otherwise the id. Needs the engine's name-serving rule reachable from plugin-audit: exported as one engine API from @objectstack/objectql (outside this order's file surface) or copied into plugin-audit (a second de-facto contract that drifts). Adds up to one refused-id check plus one elevated name read per write per declaring target on the hot path Option A+ keeps lean. Business need: same zero measured pull as A. Effort: M, two packages, plus pins mirroring the rest data-reference-name-visible suite."
      ],
      "recommendation": "A, because on the long-term axis it keeps one read rule for every title an activity row writes with no second copy of the engine's name rule, it is fail-closed on the error-proofing axis, and there is zero measured pull for B in this repo (startup-focus axis: no widening without pull). If a deployment shows the pull (a declaring field that is tracked or used in a milestone token), B should land once, as one exported engine read used by both activity paths, never as a copy in plugin-audit."
    }
  ],
  "out_of_scope_findings": [],
  "security_findings": "withheld"
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-steve · session_01ADHkmRiaNzHVY81pCjZrpv

席位核对 · ACCEPT · Head-sha 7c093c01a1de80c60494979c5ade5751fd3a94d6

  • 形态: draft → main, no Fixes # (no-card order from this seat), title and body state the hardening rule only. Diff: audit-writers.ts (+26/−17: both summary call sites pass the hook's api instead of an elevated reader; the resolver's docblock states the rule), one new 11-case pin file, one root changeset (@objectstack/plugin-audit patch). +394/−17, no governed path, no Tier H trigger.
  • 前提实测: red first on origin/main bf76922925: 7 of 11 pins red, the 4 controls green (PR body). Seat read the diff: the read keeps its shape (one id: { $in } read per distinct target object), only its reader changes, so the audit hot-path read budget (Option A+) is unchanged.
  • 门禁: check-runs on this head: 33 success, 16 skipped by path, 0 failing, 0 pending (read 2026-11-16T23:48Z). Ablations M1/M2 each turn 4 and 3 pins red and restore to the HEAD blob.
  • 接受的偏差: HTML attribution first line and signed: trailer as ordered; model-free commit trailers per AGENTS.md.
  • 范围外去向: one sub-question (whether a declaring lookup's name-visibility key should widen what activity rows name) is NOT escalated: this PR keeps activity rows on the record label's existing rule (fix(plugin-audit): name a lookup-titled record by its target's title in activity rows, and word boolean changes per locale #34172), and widening it has zero measured pull in this repo (0 declaring fields outside fixtures). Any future pull re-opens it as one engine read shared by both activity paths. Skills-docs: not owed (Metadata-protocol: none). Further findings: withheld, carried privately.
  • L2: not owed: none of the four contract faces is touched (no schema, no governed text, Clause-②: no, no narrowing arm).
  • 落地条款: seat lands: ready + auto-merge now.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 16, 2026 23:49
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 047f37b Nov 17, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/activity-summary-titles-in-writer-scope branch November 17, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant